package com.java.base.exercise.current;

import sun.awt.windows.ThemeReader;

/**
 * @Author RenPu
 * @Date 2021/8/31 15:57
 * @Version 1.0
 * @Description: Thread中sleep状态是不释放 synchronized锁的演示
 **/
public class Thread_Sleep implements Runnable {

    public static void main(String[] args) {
        Thread_Sleep thread_sleep = new Thread_Sleep();
        new Thread(thread_sleep).start();
        new Thread(thread_sleep).start();

    }


    @Override
    public void run() {
        syn();
    }


    private synchronized void syn() {
        System.out.println(Thread.currentThread().getName() + ": 获取到了 moniter锁");
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + ": 释放了 moniter锁");
    }


}


